<template>
  <HModal title="数据字典明细" @ok="close"
          @mousedown.native.stop :visible="visible"
          @cancel="close">
    <HTable
      :pagination="false" :configurable="false" select="false"
      :columns="columns" :data-source="dataSorce" size="small"/>
  </HModal>
</template>
<script>
import HModal from '@comp/hhd/HModal/HModal.vue';
import HTable from '@comp/hhd/HTable/HTable.vue';
import {getAction} from '@api/manage';

export default {
  name: 'SystemDictDetailModal',
  components: {
    HTable,
    HModal
  },
  data() {
    return {
      visible: false,
      columns,
      dataSorce: [],
      dict: {}
    };
  },
  methods: {
    setData(dict) {
      this.dict = dict;
      this.loadDictItems();
      this.open();
    },
    open() {
      this.visible = true;
    },
    close() {
      this.visible = false;
    },
    loadDictItems() {
      getAction('/sys/dictItem/list', {dictId: this.dict.id}).then(({result}) => {
        this.dataSorce = result.records;
      });
    },
  }
};
const columns = [
  {
    title: '名称',
    dataIndex: 'itemText'
  },
  {
    title: '数据值',
    dataIndex: 'itemValue'
  }
];
</script>